<?php
class ClientOrder extends ClientOrderPeer
{
	function ClientOrder()
	{
		parent::ClientOrderPeer();
	}
	
	
	public static function getAllOrders($invoice_id)
	{
		$database = new Database();
		if ($active != 1)
			$active = 0;
		if ($invoice_id)
			$query = "SELECT id FROM client_order WHERE invoice_id=".$invoice_id;
		else
			$query = "SELECT id FROM client_order";
		$result = $database->query($query);
		$ids = $database->fetch_array($result);
		$client_orders = array();
		foreach ($ids as $id) {
			$order = new ClientOrder();
			$order->select($id['id']);
			$client_orders[] = $order;
		}
		return $client_orders;
	}
	
	
	public function count_day() // this function will calculate the number of days that client rent hotel or transfer vehicle
	{
		$start_date = $this->getstart_date();
		$end_date = $this->getend_date();
		if ($start_date && $end_date) {
			return round(abs(strtotime($end_date)-strtotime($start_date))/86400);
		}
	}
}
?>